package com.tanhua.server.controller;

import com.tanhua.server.service.BaiduService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/baidu")
public class BaiduController {
//    POST/baidu/location

    @Autowired
    private BaiduService baiduService;

    @PostMapping("/location")
    public ResponseEntity saveLocation(@RequestBody Map map){
//        经度
       Double longitude = (Double) map.get("longitude");
//        纬度
       Double latitude = (Double) map.get("latitude");
//        位置描述
        String addrStr = (String) map.get("addrStr");

        System.out.println("saveLocation:"+map);

      return   baiduService.saveLocation(longitude,latitude,addrStr);
    }




}
